package com.chrono.stock.models;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.chrono.stock.dao.model.EntityModel;

@Entity
@Table( name = "CLIENTS" )
public class Client implements EntityModel{

	@Id
	@GeneratedValue(generator="increment")
	@GenericGenerator(name="increment", strategy = "increment")
    private Long id;
	
    private String nom;
    
    private String adresse;

    @ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name="CLIENT_TELEPHONE", 
    joinColumns={@JoinColumn(name="CLIENT_ID")}, 
    inverseJoinColumns={@JoinColumn(name="TELEPHONE_ID")})
    private Set<Telephone> tels = new HashSet<Telephone>();
    
	@Temporal(TemporalType.TIMESTAMP)
    private Date created;
    
    public Client(){}

	public Set<Telephone> getTels() {
		return tels;
	}

	public void addTels(Telephone tels) {
		this.tels.add(tels);
	}
	
	public void setTels(Set<Telephone> tels) {
		this.tels = tels;
	}
    
    

}
